package com.cpedu;

import com.cpedu.mapper.UserMapper1;
import com.cpedu.user.User;
import org.apache.ibatis.io.Resources;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.ibatis.session.SqlSessionFactoryBuilder;

import java.io.IOException;
import java.io.InputStream;
import java.util.List;
//代理开发
public class TestSelectAll2 {
    public static void main(String[] args) throws IOException {
        String resource = "mybatis-config.xml";
        InputStream inputStream = Resources.getResourceAsStream(resource);
        SqlSessionFactory sqlSessionFactory = new SqlSessionFactoryBuilder().build(inputStream);

        SqlSession sqlSession = sqlSessionFactory.openSession();
        //使用代理对象
        UserMapper1 mapper = sqlSession.getMapper(UserMapper1.class);
        List<User> users = mapper.selectAllUser();
        System.out.println(users);

//        for (User o :users) {
//            System.out.println(users);
//        }

    }
}
